﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using L = Science.Mathematics.LinearAlgebra;

namespace Strang3Ed.Chapter04.Section2
{
    public class Example01
    {
        public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            double[] x = { 1.0, 1.0, 1.0 };

            L.Vector b = new L.Vector(x);

            L.Vector[] a = new L.Vector[1];
            a[0] = new L.Vector(3);
            a[0][0] = 1.0;
            a[0][1] = 2.0;
            a[0][2] = 2.0;

            L.Subspace s = new L.Subspace(a);

            L.Projection obj = new L.Projection(s, b);
            
            result += obj.OntoSubspace.ToString() + "\r\n";

            result += obj.Error.ToString() + "\r\n";
        }
    }
}
/*
0.555555555555556
1.11111111111111
1.11111111111111

0.444444444444444
-0.111111111111111
-0.111111111111111
*/


